import { Color } from "three";
import { GLTF } from "three/examples/jsm/Addons.js";
import { ThreeLoader } from "../three/loader";

export class AnchorGltf {
    private threeLoader = new ThreeLoader();

    loader(): Promise<GLTF> {
        return new Promise(resolve => {
            this.threeLoader.gltf().load('./assets/models/anchor.gltf', object => {
                object.scene.traverse((child: any) => {
                    if (child.isMesh) {
                        child.castShadow = true;
                        child.receiveShadow = true;
                        child.material.metalness = .4;
                        child.name.includes('黄') && (child.material.color = new Color(0xfffc00))
                    }
                });
                object.scene.rotation.y = Math.PI / 2;

                resolve(object)
            })
        })
    }
}

